x86/apic: allow enabling x2APIC mode regardless of interrupt remapping
authorRoger Pau Monné <roger.pau@citrix.com>
Fri, 20 Dec 2019 15:29:22 +0000 (16:29 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 20 Dec 2019 15:29:22 +0000 (16:29 +0100)
commitb1710040ca9628a6517bfc06f87dcbb670f8743e
tree2fac257663ee95f55dc6c883f43e539b4303390a
parent3d05407025ed1f83f492f81ba8175fa26b1e2fb3
x86/apic: allow enabling x2APIC mode regardless of interrupt remapping

x2APIC mode doesn't mandate interrupt remapping, and hence can be
enabled independently. This patch enables x2APIC when available,
regardless of whether there's interrupt remapping support.

This is beneficial specially when running on virtualized environments,
since it reduces the amount of vmexits. For example when sending an
IPI in xAPIC mode Xen performs at least 3 different accesses to the
APIC MMIO region, while when using x2APIC mode a single wrmsr is used.

The following numbers are from a lock profiling of a Xen PV shim
running a Linux PV kernel with 32 vCPUs and xAPIC mode:

(XEN) Global lock flush_lock: addr=ffff82d0804af1c0, lockval=03190319, not locked
(XEN)   lock:656153(892606463454), block:602183(9495067321843)

Average lock time:   1360363ns
Average block time: 15767743ns

While the following are from the same configuration but with the shim
using x2APIC mode:

(XEN) Global lock flush_lock: addr=ffff82d0804b01c0, lockval=1adb1adb, not locked
(XEN)   lock:1841883(1375128998543), block:1658716(10193054890781)

Average lock time:   746588ns
Average block time: 6145147ns

Enabling x2APIC has halved the average lock time, thus reducing
contention.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/apic.c